<template>
  <div>
    <h3>SubItem组件</h3>
    <p>已知库存数: {{num}}</p>
    <button @click="subFn">库存-1</button>
    <button @click="asyncFn2">延迟两秒，库存-5</button>
  </div>
</template>

<script>
import { mapState, mapMutations, mapActions } from 'vuex'
export default {
  computed: {
    ...mapState(['num'])

  },
  methods: {
    ...mapMutations(['subNum']),
    ...mapActions(['asyncSubNum']),
    subFn () {
      this.subNum(5)
    },
    asyncFn2 () {
      this.asyncSubNum(5)
    }
  }
}
</script>
